package com.company.woye.taiorcheckSize.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.company.woye.R;
import com.company.woye.taiorcheckSize.bean.TaiorPartBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class TaiorPartDetailListviewAdapter extends BaseAdapter {

    private LayoutInflater inflater;
    private Context mContext;
    private List<TaiorPartBean.DataBean.YbccbListBean> listBeans;

    public TaiorPartDetailListviewAdapter(Context context, List<TaiorPartBean.DataBean.YbccbListBean> listBeans) {
        this.inflater = LayoutInflater.from(context);
        this.mContext = context;
        this.listBeans = listBeans;
    }

    @Override
    public int getCount() {
        return listBeans.size();
    }

    @Override
    public Object getItem(int position) {
        return listBeans.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHodler = null;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.intem_taior_detail_a, parent, false);
            viewHodler = new ViewHolder(convertView);
            convertView.setTag(viewHodler);
        } else {
            viewHodler = (ViewHolder) convertView.getTag();
        }
        viewHodler.tvCode.setText(listBeans.get(position).getXh());
        viewHodler.tvPart.setText(listBeans.get(position).getBw());
        return convertView;
    }

    static
    class ViewHolder {
        @BindView(R.id.tv_code)
        TextView tvCode;
        @BindView(R.id.tv_part)
        TextView tvPart;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
